home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / +ORC / Orc pac 42B / FILEZ.ZIP / PATCHSRC.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-08-12  |  4.9 KB  |  202 lines

  1. ;***************************************************************************
  2. ;                                YAIP
  3. ;               Yet Another (pseudoIntelligent!!!) Patcher
  4. ;                     Written by Oskar Nurb, 14-4-97
  5. ;                        oskar_nurb@nym.alias.net
  6. ;       
  7. ;  GREETZ: +ORC, +Gthorne, Fravia+ and all the readers of RevEngE
  8. ;
  9. ;  Please improve and expread this program. I consider I must learn a lot
  10. ;  before making good software... I'm on the commercial standards now! :)
  11. ;
  12. ;  Yeah, I can see your faces... You are surely thinking: Another patcher?
  13. ;  Yes, but this patcher is written in ASM, and it isn't based on the file
  14. ;  offset method that most pathers out there use. It searches and patches.
  15. ;  There is a BIG difference between both metods. Using this code you crack
  16. ;  several versions of a program :)
  17. ;
  18. ;  As it is written in ASM, you can generate a .COM and encrypt it as you
  19. ;  wish. Or you can just build a C program that uses this code.
  20. ;
  21. ;  Enjoy!
  22. ;
  23. ;***************************************************************************
  24.  
  25.                 .286
  26.         .model small
  27.         .code
  28.                 org 100h
  29.  
  30. bufsize equ     20000
  31. CR      equ     0dh
  32. LF      equ     0ah
  33.  
  34. ; As usual, some directives.
  35.  
  36.  
  37. start:
  38.         push    cs
  39.         pop     ds
  40.         mov     ax,3d02h
  41.         mov     dx,offset fname
  42.         int     21h
  43.  
  44. ; Please chech HelpPc for a refference if you are a newbye.
  45.  
  46.         jc      Erroropening
  47.         mov     word ptr cs:[Fhandle],ax
  48.         jmp     prinbuc
  49.  
  50. ; I love to write odd modules :)
  51. ; Why can't you see any procs? Because I wrote this in order to
  52. ; be heavily compiler-encrypted... And I thought it would be a
  53. ; mess otherwise.
  54.  
  55. Erroropening:
  56.         mov     dx,offset eamsg
  57.         mov     ah,09
  58.         int     21h
  59.  
  60. ; Don't you think I'm a very user-friendly programmer?
  61.  
  62.         mov     ah,4ch
  63.         int     21h
  64.  
  65.  
  66. ; Here starts the search engine. You only have to put that
  67. ; search string in little bytes. Or even better, you can
  68. ; write a function that only needs a string as arg.
  69.  
  70. ;All the jc stuff is there in order to left the read proc
  71. ;as free as possible. If you don't like it, just modify it.
  72. ;I personally don't care.
  73.  
  74. searchbuc:
  75.         call    read
  76.         jc      finalox
  77. prinbuc:
  78.         cmp     ah,54h
  79.         jne     searchbuc
  80.         call    read
  81.         jc      finalox
  82.         cmp     ah,75h
  83.         jne     prinbuc
  84.         call    read
  85.         jc      finalox
  86.         cmp     ah,72h
  87.         jne     prinbuc
  88.         call    read
  89.         jc      finalox
  90.         cmp     ah,62h
  91.         jne     prinbuc
  92.  
  93. ;Bingo. If you are here, you've found the match.
  94.  
  95. ;Let's take our File Pointer
  96.  
  97.         mov     ax,4201h
  98.         mov     bx,word ptr cs:[Fhandle]
  99.         mov     cx,0
  100.         mov     dx,0
  101.         int     21h
  102.  
  103. ;Let's manage it to point the start of string.
  104.  
  105.         mov     bx,word ptr cs:[Fhandle]
  106.         mov     cx,dx
  107.         mov     dx,ax
  108.         sub     dx,word ptr cs:[Inbuf]
  109.         add     dx,word ptr cs:[readed]
  110.         sub     dx,3
  111.         mov     ax,4200h
  112.         int     21h
  113.  
  114. ;Let's write the patch
  115.  
  116.         mov     bx,word ptr cs:[Fhandle]
  117.         mov     ah,40h
  118.         mov     cx,3
  119.         push    cs
  120.         pop     ds
  121.         mov     dx,offset wbuff
  122.         int     21h
  123.  
  124.  
  125. ;Close file
  126.  
  127.  
  128.         mov     bx,word ptr cs:[Fhandle]
  129.         mov     ah,3eh
  130.         int     21h
  131.  
  132. ;Bye dear user!
  133.  
  134.         mov     dx,offset hecho
  135.         mov     ah,09
  136.         int     21h
  137.  
  138.         mov     ah,4ch
  139.         int     21h
  140.  
  141. wbuff   db      90h,90h,90h
  142. hecho   db      'OK!!$'
  143.  
  144. finalox:
  145.         mov     ah,4ch
  146.         int     21h
  147.  
  148. ; This is our read function, with a little buffer, of course.
  149. ; It is free of internal weird/end jumps for easy modification
  150. ; pourposes. It just returns CF on EOF, and if not CF the next byte of the
  151. ; file (stream??) in AH. You can surely write it better, but, hey,
  152. ; I'm not a programmer! :)
  153. ; May be some day... :)
  154.  
  155. read:
  156.         push    si
  157.         mov     si,word ptr cs:[readed]
  158.         cmp     si,word ptr cs:[Inbuf]
  159.         jne     cont
  160.         call    fullbuf
  161.         jnc     cont
  162.         pop     si
  163.         stc
  164.         ret
  165. cont:
  166.         clc
  167.         mov     ah,byte ptr cs:[Buff+si]
  168.         inc     word ptr cs:[readed]
  169.         pop     si
  170.         clc
  171.         ret
  172.  
  173. fullbuf:
  174.         mov     bx,word ptr cs:[Fhandle]
  175.         mov     ah,3fh
  176.         mov     cx,bufsize
  177.         push    cs
  178.         pop     ds
  179.         mov     dx,offset Buff
  180.         int     21h
  181.         jc      error
  182.         cmp     ax,0
  183.         je      error
  184.         mov     word ptr cs:[Inbuf],ax
  185.         mov     word ptr cs:[readed],0
  186.         clc
  187.         ret
  188. error:
  189.         stc
  190.         ret
  191.  
  192.  
  193. fname   db      'test.exe',0
  194. eamsg   db      'Error opening file',CR,LF,'$'
  195.  
  196. readed  dw      0
  197. Fhandle dw      ?
  198. Inbuf   dw      ?
  199. Buff    dw      bufsize dup(?)
  200.  
  201. end start
  202.